#include <cstdio>
#include<stdlib.h>
#include<unistd.h>
#include<dirent.h>
#include"epllo_server.h"

int main(int argc,char* argv[])
{
    //if (argc < 3) {
    //    printf("eg:./a.out port path\n");
    //    exit(1);
    //}

    ////端口
    //int port = atoi(argv[1]);
    //修改进程工作目录  方便后续操作  /home/pop/projects/www
    int ret = chdir("/home/pop/projects/www");
    if (ret == -1) {
        perror("chdir error\n");
        exit(1);
    }
    DIR* dir = opendir("./");
    if (dir == NULL)
    {
        perror("opendir error\n");
        exit(1);
    }
    //读目录
    struct dirent* ptr = NULL;

    printf("当前目录:\n");
    while ((ptr == readdir(dir)) != NULL)
    {
        printf("%s\n", ptr->d_name);
    }
    closedir(dir);
    //启动epoll 模型
    printf("hello from HeimaWebServer!\n");
    epllo_run(80);

    return 0;
}